<script setup>
import { useRoute } from 'vue-router';

const goodlist = [
  {
    id: 1,
    name: '时尚连衣裙',
    desc: '简约时尚的连衣裙，适合各种场合。',
    price: 499,
    picture: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.uz_AnnENlaeF20tqy2PjYAAAAA?rs=1&pid=ImgDetMain'
  },
  {
    id: 2,
    name: '修身牛仔裤',
    desc: '经典的修身牛仔裤，百搭又舒适。',
    price: 399,
    picture: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.uz_AnnENlaeF20tqy2PjYAAAAA?rs=1&pid=ImgDetMain'
  },
  {
    id: 3,
    name: '商务衬衫',
    desc: '高品质的商务衬衫，尽显专业气质。',
    price: 299,
    picture: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.uz_AnnENlaeF20tqy2PjYAAAAA?rs=1&pid=ImgDetMain'
  },
  {
    id: 4,
    name: '休闲外套',
    desc: '时尚休闲的外套，保暖又时尚。',
    price: 599,
    picture: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.uz_AnnENlaeF20tqy2PjYAAAAA?rs=1&pid=ImgDetMain'
  },
  {
    id: 5,
    name: '运动套装',
    desc: '舒适的运动套装，适合运动和休闲。',
    price: 499,
    picture: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.uz_AnnENlaeF20tqy2PjYAAAAA?rs=1&pid=ImgDetMain'
  },
    {
    id: 6,
    name: '运动套装',
    desc: '舒适的运动套装，适合运动和休闲。',
    price: 499,
    picture: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.uz_AnnENlaeF20tqy2PjYAAAAA?rs=1&pid=ImgDetMain'
  }
];

const route = useRoute()
const query = route.query.name
console.log(query);

</script>

<template>
  <div class="container">
    <div class="home-product">
      <div class="goodList-box">
        <ul class="goods-list">
          <li v-for="good in goodlist" :key="good.id">
            <RouterLink :to="{name: 'gooddetail', params: {goodid: good.id}}" class="goods-item">
            <img :src="good.picture" alt="" />
              <p class="name ellipsis">{{ good.name }}</p>
              <p class="desc ellipsis">{{ good.desc }}</p>
              <p class="price">&yen;{{ good.price }}</p>
            </RouterLink>
          </li>
        </ul>
      </div>
    </div>
  </div>
  
</template>


<style scoped lang="scss">
  .home-product {
    background: #fff;
    margin: 20px 0 20px 0;
    display: flex;

    .cover {
      width: 240px;
      height: 610px;
      margin-right: 10px;
      position: relative;

      img {
        width: 100%;
        height: 100%;
      }

      .label {
        width: 188px;
        height: 66px;
        display: flex;
        font-size: 18px;
        color: #fff;
        line-height: 66px;
        font-weight: normal;
        position: absolute;
        left: 0;
        top: 50%;
        transform: translate3d(0, -50%, 0);

        span {
          text-align: center;

          &:first-child {
            width: 76px;
            background: rgba(0, 0, 0, 0.9);
          }

          &:last-child {
            flex: 1;
            background: rgba(0, 0, 0, 0.7);
          }
        }
      }
    }


    .goods-list {
      width: 1240px;
      display: flex;
      flex-wrap: wrap;

      li {
        width: 240px;
        height: 300px;
        margin-right: 10px;
        margin-bottom: 10px;

        &:nth-last-child(-n + 4) {
          margin-bottom: 0;
        }

        &:nth-child(5n) {
          margin-right: 0;
        }
      }
    }

    .goods-item {
      display: block;
      width: 240px;
      padding: 20px 30px;
      text-align: center;
      transition: all .5s;
      background: #fff;


      &:hover {
        transform: translate3d(0, -3px, 0);
        box-shadow: 0 3px 8px rgb(0 0 0 / 20%);
      }

      img {
        width: 160px;
        height: 160px;
      }

      p {
        padding-top: 10px;
      }

      .name {
        font-size: 16px;
      }

      .desc {
        color: #999;
        height: 29px;
      }

      .price {
        color: $priceColor;
        font-size: 20px;
      }
    }
  }

</style>